<?php

class DP_Controller_Plugin_Layout extends Zend_Controller_Plugin_Abstract
{
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $module = $request->getModuleName();

        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
            'ViewRenderer'
        );

        $view = $viewRenderer->view;

		$moduleParams = $view->$module;
		$view->addBasePath(APPLICATION_PATH . '/modules/' . $module . '/views/');
		$view->addHelperPath(APPLICATION_PATH . '/modules/' . $module . '/views/helpers/', 'Dp_Module_' . strtoupper($module) . '_View_Helper');

		$layout = Zend_Layout::startMvc();
		$layout->setLayoutPath(APPLICATION_PATH . '/modules/' . $module . '/views/layouts')
               ->setLayout('layout');

        /*$view->addBasePath($moduleParams['basePath']);
        $view->addHelperPath($moduleParams['helperPath'],
        $moduleParams['helperPathPrefix']);

        $layout = Zend_Layout::startMvc();
        $layout->setLayoutPath($moduleParams['layoutPath'])
               ->setLayout($moduleParams['layout']);*/

    }
}

?>
